define(["Zepto", 
        "underscore", 
        "Backbone", 
        "Handlebars", 
        "views/employeelistview", 
        "collections/employeecollection", 
        "text!templates/search-page.html" // template
], function($, _, Backbone, Handlebars, EmployeeListView, EmployeeCollection, template) {

	
	// ho bisogno:
	// vista delle liste
	// una collezione emplyee
	// un template 
	
    var EmployeeListPage = Backbone.View.extend({

        template: Handlebars.compile(template),

        render: function(eventName) {
        	// el.html del template pagina
            this.$el.html(this.template);
            // istanzio una vista delle liste
            this.listView = new EmployeeListView({
                el: $('ul', this.el),
                model: this.model
            });
            this.listView.render();
            return this;
        },

        events: {
            "keyup .search-query": "search"
        },

        search: function(event) {
            var key = $('.search-query').val();
            console.log('search ' + key);
            this.model.findByName(key);
        }
    });

    return EmployeeListPage;

});